package com.hzqy.service.statistics;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.statistics.ActivityIndustryDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.PmsUserVo;
import com.hzqy.web.vo.StatDataActivityIndustryVo;
import com.hzqy.web.vo.StatDataListenTop20Vo;

@Service
public class ActivityIndustryServiceBean extends GenericServiceBean<PmsUserVo, ActivityIndustryDao, Integer>{
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	@Resource
	private ActivityIndustryDao activityIndustryDao;

	@Override
	public ActivityIndustryDao getEntityDao() {
		return activityIndustryDao;
	}
	
	public Map<String, Object> selectActivityIndustryList(StatDataActivityIndustryVo statDataActivityIndustryVo, int curPage,int pageSize) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = activityIndustryDao.selectActivityIndustryCount(statDataActivityIndustryVo);
		map.put("total", rowCount);
		if(rowCount > 0 && curPage > 0 && pageSize > 0) {
			map.put("firstResult", (curPage-1)*pageSize);
			map.put("maxResults", pageSize);
			map.put("f_sdaia_type", statDataActivityIndustryVo.getF_sdaia_type());
			map.put("beginDate", statDataActivityIndustryVo.getBeginDate());
			map.put("endDate", statDataActivityIndustryVo.getEndDate());
			map.put("monthDate", statDataActivityIndustryVo.getMonthDate());
			map.put("weekDate", statDataActivityIndustryVo.getWeekDate());
			map.put("f_sdaia_areaid", statDataActivityIndustryVo.getF_sdaia_areaid());
			List<StatDataActivityIndustryVo> results = activityIndustryDao.selectActivityIndustryList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataActivityIndustryVo>());
		}
		return map;
	}

	public Map<String, Object> selectActivityIndustryExcelList(StatDataActivityIndustryVo statDataActivityIndustryVo) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = activityIndustryDao.selectActivityIndustryCount(statDataActivityIndustryVo);
		map.put("total", rowCount);
		if(rowCount > 0) {
			map.put("f_sdaia_type", statDataActivityIndustryVo.getF_sdaia_type());
			map.put("beginDate", statDataActivityIndustryVo.getBeginDate());
			map.put("endDate", statDataActivityIndustryVo.getEndDate());
			map.put("monthDate", statDataActivityIndustryVo.getMonthDate());
			map.put("weekDate", statDataActivityIndustryVo.getWeekDate());
			map.put("f_sdaia_areaid", statDataActivityIndustryVo.getF_sdaia_areaid());
			List<StatDataActivityIndustryVo> results = activityIndustryDao.selectActivityIndustryExcelList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataListenTop20Vo>());
		}
		return map;
	}
}
